package com.xiaoxiao.springbootstudy.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xiaoxiao.springbootstudy.pojo.Item;
import com.xiaoxiao.springbootstudy.pojo.vo.ItemCond;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author XiaoXiao
 * @description 针对表【t_item】的数据库操作Mapper
 * @createDate 2025-05-28 14:12:06
 * @Entity com.xiaoxiao.springbootstudy.pojo.Item
 */
public interface ItemMapper extends BaseMapper<Item> {
    @Select("""
            <script>
            select item.*,
                           type.cate_name,
                           brand.brand_name,
                           store.store_name,
                           supply.supply_name,
                           place.place_name,
                           unit.unit_name
                    from t_item item
                             inner join t_categroy type on type.id = item.type_id
                             inner join t_brand brand on brand.brand_id = item.brand_id
                             inner join t_store store on store.store_id = item.store_id
                             inner join t_supply supply on supply.supply_id = item.supply_id
                             inner join t_place place on place.place_id = item.place_id
                             inner join t_unit unit on unit.unit_id = item.unit_id
                             <where>
                                    <if test="itemNum!=null and itemNum!=''">
                                            item.item_num=#{itemNum}
                                    </if>
                                    <if test="itemName!=null and itemName!=''">
                                            and item.item_name=#{itemName}
                                    </if>
                                    <if test="statue!=null">
                                            and item.statue=#{statue}
                                    </if>
                             </where>
            </script>""")
    List<Item> queryItemListMapper(ItemCond itemCond);


}




